
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        购货单生成
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../css/main.css" media="all">
    <script src="../js/jquery.min.js"></script>
<!--    <script type="text/javascript" src="../lib/loading/okLoading.js"></script>-->
    <style>
        .imgs{display: none;}
    </style>
    <script>
        $.ajax({
            type:"post",
            url:"../../supplier/selectAllSupplier.do",
            success:function (data) {
                console.log(data);
                var content = "";
                console.log(data.data.length);
                for(var i = 0;i<data.data.length;i++){
                    content = content + "<option id='supplier' value="+"\""+data.data[i].sid+"\""+">"+data.data[i].sname + "</option>\n";
                }
                var a = $("#sid").html(content);
            }
        });

        $.ajax({
            type:"post",
            url:"../../item/selectAllItem.do",
            success:function (data) {
                console.log(data);
                var content = "";
                console.log(data.data.length);
                for(var i = 0;i<data.data.length;i++){
                    content = content + "<option id='item' value="+"\""+data.data[i].iid+"\""+">"+data.data[i].name + "</option>\n";
                }
                var a = $("#iid").html(content);
            }
        });
        $.ajax({
            type:"post",
            url:"../../stock/selectAllStock.do",
            success:function (data) {
                console.log(data);
                var content = "";
                console.log(data.data.length);
                for(var i = 0;i<data.data.length;i++){
                    content = content + "<option id='stock' value="+"\""+data.data[i].stid+"\""+">"+data.data[i].stname + "</option>\n";
                }
                var a = $("#stid").html(content);
            }
        });

        $.ajax({
            type:"post",
            url:"../../employee/selectAllEmployee.do",
            success:function (data) {
                console.log(data);
                var content = "";
                console.log(data.data.length);
                for(var i = 0;i<data.data.length;i++){
                    content = content + "<option id='employer' value="+"\""+data.data[i].eid+"\""+">"+data.data[i].ename + "</option>\n";
                }
                var a = $("#eid").html(content);
            }
        });

    </script>
    <style>
        .td{
            padding-top: 15px;
            padding-bottom: 15px;
            padding-left: 50px;
            padding-right: 50px;
        }
    </style>

</head>
<body>
<div class="x-body">

        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <input type="hidden" name="id" value="">
                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>收购商名称
                        </label>
                        <div class="layui-input-block">
                            <select style="display: block;font-size: 17px;height: 37.5px"  id="sid">

                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>商品名称
                        </label>
                        <div class="layui-input-block">
                            <select style="display: block;font-size: 17px;height: 37.5px"  id="iid">

                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>单价
                        </label>
                        <div class="layui-input-block" >
                            <input type="text" id="price1" autocomplete="off" placeholder="请输入数字"
                                   class="layui-input" required="number" lay-verify="number" >
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>数量
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="count" autocomplete="off" placeholder="请输入数字"
                                   class="layui-input" required="number" lay-verify="number" value="">
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>仓库
                        </label>
                        <div class="layui-input-block">
                            <select style="display: block;font-size: 17px;height: 37.5px"  id="stid">

                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>时间
                        </label>
                        <div class="layui-input-block">
                            <input type="date"  style="height: 35px" id="date">
                        </div>
                    </div>

                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>总价
                        </label>
                        <div class="layui-input-block">
                            <input type="text"  autocomplete="off" placeholder="请输入数字"
                                   class="layui-input" id="total" required="number" lay-verify="number" value="" style="width:100px">
                        </div>
                    </div>

                    <div class="layui-form-item" style="display: inline-block">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>采购人
                        </label>
                        <div class="layui-input-block">
                            <select style="display: block;font-size: 17px;height: 37.5px"  id="eid">

                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">
                            <span class='x-red'></span>备注
                        </label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" class="layui-textarea" id="info"></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item" style="text-align: center">
                        <button class="layui-btn" type="button" lay-filter="add" onclick="saveButton()">
                            生成购货单
                        </button>
                    </div>

                </div>

                <form class="layui-form layui-form-pane" action="../../buy/creatBuyBill.do" id="add" method="post" onsubmit="aaa()">
                    <table id="table1" border="|" style="font-size: 14px">
                        <tr>
                            <td class="td">商品名称</td>
                            <td class="td">供货商</td>
                            <td class="td">单价</td>
                            <td class="td">数量</td>
                            <td class="td">仓库</td>
                            <td class="td">总价</td>
                            <td class="td">时间</td>
                            <td class="td">采购人</td>
                            <td class="td">备注</td>
                        </tr>
                    </table>
                    <div class="layui-form-item" style="text-align: center;margin-top: 10px">
                        <button class="layui-btn" type="submit" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>
                    <input type="hidden">
                </form>
            </div>

        </div>


</div>
<script>
    var i = 0;
    function saveButton() {
        var table = $("#table1");
        table.append("<tr>\n" +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].iid'"+" value="+$("#item").attr("value")+">"+$("#item").text()+"</td>\n" +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].sid'"+" value="+$("#supplier").attr("value")+">"+$("#supplier").text()+"</td>\n" +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].price'"+" value="+$("#price1").val()+">"+$("#price1").val()+"</td>\n" +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].count'"+" value="+$("#count").val()+">"+$("#count").val()+"</td>\n" +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].stid'"+" value="+$("#stock").attr("value")+">"+$("#stock").text()+"</td>\n"+
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].total'"+" value="+$("#total").val()+">"+$("#total").val()+"</td>\n"  +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].date'"+" value="+$("#date").val()+">"+$("#date").val()+"</td>\n"  +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].eid'"+" value="+$("#employer").attr("value")+">"+$("#employer").text()+"</td>\n"  +
            "                <td class=\"td\">"+"<input type='hidden' name='intos["+ i +"].info'"+" value="+$("#info").val()+">"+$("#info").val()+"</td>\n"  +
            "            </tr>");

        i = i + 1;
    }
</script>
<script>
   function aaa() {
       alert("成功提交")
   }


</script>

<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/x-layui.js" charset="utf-8"></script>
<!--<script>-->
<!--    layui.use(['element','layer','form'], function(){-->
<!--        $ = layui.jquery;//jquery-->
<!--        lement = layui.element();//面包导航-->
<!--        layer = layui.layer;//弹出层-->
<!--        form = layui.form();-->
<!--        okLoading.close($);-->

<!--        //监听提交-->
<!--        form.on('submit(add)', function(data){-->
<!--            var buildings_name=$("input[name='buildings_name']").val();-->
<!--            var households=$("input[name='households']").val();-->
<!--            if(buildings_name==""){-->
<!--                layer.msg('栋数名称不能为空！',{icon:5,time:2000});return false;-->
<!--            }-->
<!--            if(households==""){-->
<!--                layer.msg('总户数不能为空！',{icon:5,time:2000});return false;-->
<!--            }-->
<!--            var data = data.field;-->
<!--            $.ajax({-->
<!--                type:"post",-->
<!--                url:"xxx",-->
<!--                data:data,-->
<!--                dataType:"json",-->
<!--                success:function(data){-->
<!--                    if(data.status==1){-->
<!--                        layer.msg(data.info, {icon: 6,time:2000},function () {-->
<!--                            window.parent.location.reload();-->
<!--                            var index = parent.layer.getFrameIndex(window.name);-->
<!--                            parent.layer.close(index);-->
<!--                        });-->
<!--                        return false;-->
<!--                    }-->
<!--                    else{-->
<!--                        layer.msg(data.info,{icon:5,time:2000});return false;-->
<!--                    }-->
<!--                }-->

<!--            });-->

<!--        });-->

<!--    })-->
<!--</script>-->

</body>
</html>